package com.demon.example.api;

import com.demon.example.model.entity.UserPO;
import com.demon.example.service.UserService;
import com.demon.framework.common.model.entity.ResultVO;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class UserApi implements IUserApi {

    /**
     * 使用lombok的方式注入bean
     */
    private final UserService userService;

    @Override
    public ResultVO<UserPO> get(@RequestParam("userId") Long userId) {

        return ResultVO.SUCCESS(userService.getById(userId));
    }

    @Override
    public ResultVO<UserPO> getByPhone(String phone) {
        return ResultVO.SUCCESS(userService.getByPhone(phone));
    }
}
